using System;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows;
using JetBrains.Annotations;

namespace Triton.Common
{
	public class NotificationObject : INotifyPropertyChanged
	{
		[CompilerGenerated]
		private sealed class Class213<T>
		{
			public string string_0;

			public NotificationObject notificationObject_0;

			internal void method_0()
			{
				notificationObject_0.propertyChangedEventHandler_0?.Invoke(notificationObject_0, new PropertyChangedEventArgs(string_0));
			}
		}

		[CompilerGenerated]
		private PropertyChangedEventHandler propertyChangedEventHandler_0;

		public event PropertyChangedEventHandler PropertyChanged
		{
			[CompilerGenerated]
			add
			{
				PropertyChangedEventHandler propertyChangedEventHandler = propertyChangedEventHandler_0;
				PropertyChangedEventHandler propertyChangedEventHandler2;
				do
				{
					propertyChangedEventHandler2 = propertyChangedEventHandler;
					PropertyChangedEventHandler value2 = (PropertyChangedEventHandler)Delegate.Combine(propertyChangedEventHandler2, value);
					propertyChangedEventHandler = Interlocked.CompareExchange(ref propertyChangedEventHandler_0, value2, propertyChangedEventHandler2);
				}
				while ((object)propertyChangedEventHandler != propertyChangedEventHandler2);
			}
			[CompilerGenerated]
			remove
			{
				PropertyChangedEventHandler propertyChangedEventHandler = propertyChangedEventHandler_0;
				PropertyChangedEventHandler propertyChangedEventHandler2;
				do
				{
					propertyChangedEventHandler2 = propertyChangedEventHandler;
					PropertyChangedEventHandler value2 = (PropertyChangedEventHandler)Delegate.Remove(propertyChangedEventHandler2, value);
					propertyChangedEventHandler = Interlocked.CompareExchange(ref propertyChangedEventHandler_0, value2, propertyChangedEventHandler2);
				}
				while ((object)propertyChangedEventHandler != propertyChangedEventHandler2);
			}
		}

		[NotifyPropertyChangedInvocator]
		protected void NotifyPropertyChanged<TExp>(Expression<Func<TExp>> expression)
		{
			string string_0 = smethod_0(expression);
			if (Application.Current != null)
			{
				Application.Current.Dispatcher.BeginInvoke((Action)delegate
				{
					propertyChangedEventHandler_0?.Invoke(this, new PropertyChangedEventArgs(string_0));
				});
			}
		}

		private static string smethod_0<T>(Expression<Func<T>> expression_0)
		{
			if (expression_0.NodeType != ExpressionType.Lambda)
			{
				throw new ArgumentException("Value must be a lamda expression", "expression");
			}
			if (!(expression_0.Body is MemberExpression))
			{
				throw new ArgumentException("The body of the expression must be a memberref", "expression");
			}
			return ((MemberExpression)expression_0.Body).Member.Name;
		}
	}
}
